package com.mooc.apigateway.controller;


import com.mooc.apigateway.common.UserContext;
import com.mooc.apigateway.model.Comment;
import com.mooc.apigateway.model.User;
import com.mooc.apigateway.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("comment")
public class CommentController {

     @Autowired
     private CommentService commentService;

    @RequestMapping("leaveComment")
    public String leaveComment(String content, Long houseId){
        User user = UserContext.getUser();
        Long userId = user.getId();
        commentService.addHouseComment(houseId,content,userId);
        return "redirect:/house/detail?id=" + houseId;
    }



}
